package com.itfreer.esb.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;

import org.springframework.beans.BeanUtils;

import com.itfreer.esb.proxy.entity.AccessCountByServerEntity;
import com.itfreer.esb.proxy.entity.AccessLogEntity;
import com.itfreer.form.api.JdbcBaseEntity;

/**
 * 访问日志
 * @author gj
 *
 */
@Entity(name = "esb_access_log")
@Table(indexes = { @Index(name = "esb_access_log_server", columnList = "s_server")})
public class JdbcAccessLogEntity implements JdbcBaseEntity<AccessLogEntity>, Serializable { 
	private static final long serialVersionUID = 4673423560339517162L;
	/**
	 * 主键
	 */
	@Id
	@Column(name = "s_id", length = 200, nullable = false)
	private String id;
	
	/**
	 * 服务
	 */
	@Column(name = "s_server")
	private String server;
	
	/**
	 * 代理地址
	 */
	@Column(name = "s_proxy")
	private String proxy;
	
	/**
	 * 访问服务ip
	 */
	@Column(name = "s_access_ip")
	private String accessIp;
	
	/**
	 * 服务访问口令
	 */
	@Column(name = "s_access_token")
	private String accessToken;
	
	/**
	 * 访问时间
	 */
	@Column(name = "s_access_time")
	private Date accessTime;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getServer() {
		return server;
	}

	public void setServer(String server) {
		this.server = server;
	}

	public String getProxy() {
		return proxy;
	}

	public void setProxy(String proxy) {
		this.proxy = proxy;
	}

	public String getAccessIp() {
		return accessIp;
	}

	public void setAccessIp(String accessIp) {
		this.accessIp = accessIp;
	}

	public String getAccessToken() {
		return accessToken;
	}

	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}

	public Date getAccessTime() {
		return accessTime;
	}

	public void setAccessTime(Date accessTime) {
		this.accessTime = accessTime;
	}

	@Override
	public void from(AccessLogEntity t) {
		BeanUtils.copyProperties(t, this);
		
	}

	@Override
	public AccessLogEntity toEntity() {
		AccessLogEntity toEntity = new AccessLogEntity();
		BeanUtils.copyProperties(this, toEntity);
		return toEntity;
	}
}
